<template>
  <div>
    <el-form :inline="true" :model="formData">
      <el-form-item>
        <el-input v-model="formData.userName" placeholder="姓名" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-input v-model="formData.taskName" placeholder="任务名称" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-select v-model="formData.productId" remote  :remote-method="remoteMethod" :loading="loading">
          <el-option v-for="item in proOptions" :key="item.value" :label="item.label" :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="getFormList()">查询</el-button>
        <el-button type="primary" @click="addInfoHandle()">新增</el-button>
      </el-form-item>
    </el-form>
    <el-table
      :data="tableData"
      row-key="formList"
      border size="mini"
      height="350px"
      style="width: 100%;">
      <el-table-column fixed="left" prop="seqNo" label="序号" min-width="150">
      </el-table-column>
      <el-table-column fixed="left" prop="moudleName" label="一级模块" min-width="150">
      </el-table-column>
      <el-table-column fixed="left" prop="taskName" label="任务名称" min-width="300">
      </el-table-column>
      <el-table-column fixed="left" prop="workType" label="开发模式" min-width="150">
      </el-table-column>
      <el-table-column fixed="left" prop="startDate" label="开始日期" min-width="150">
      </el-table-column>
      <el-table-column fixed="left" prop="endDate" label="结束日期" min-width="150">
      </el-table-column>
      <el-table-column fixed="left" prop="trueEndDate" label="实际完成日期" min-width="150">
      </el-table-column>
      <el-table-column fixed="left" prop="planDays" label="计划天数" min-width="150">
      </el-table-column>
    </el-table>
    <!-- 分页信息 -->
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="pageSize"
      :total="total"
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>
    <!--弹窗-->
    <addInfo v-if="addVisible" ref="addInfo" @refreshDataList="getFormList"></addInfo>

  </div>
</template>

<script>
  import AddInfo from '../task/addTask'

  export default {
    name: 'index',
    data () {
      return {
        formData: {
          userName: '',
          taskName: '',
          productId: ''
        },
        tableData: [],
        proOptions: [],
        addVisible: false,
        loading: false,
        pageIndex: 1,
        pageSize: 10,
        totalPage: 0,
        total: 0
      }
    },
    components: {
      AddInfo
    },
    activated () {
      this.init()
    },
    methods: {
      init () {
        this.$nextTick(() => {
          this.getFormList()
        })
      },
      getFormList () {
        this.tableData = []
        // this.$http({
        //   url: this.$http.adornUrl('/task/formBaseList'),
        //   method: 'post',
        //   params: this.$http.adornParams({
        //     'userName': this.dataForm.userName,
        //     'taskName': this.dataForm.taskName,
        //     'productId': this.dataForm.productId,
        //     'pageNumber': this.pageIndex,
        //     'pageSize': this.pageSize
        //   }, false)
        // }).then(({data}) => {
        //   if (data && data.code === 0) {
        //     this.tableData = data.data.data;
        //     this.totalPage = data.data.pages;
        //     this.total = data.data.total;
        //   } else {
        //     this.tableData = []
        //     this.totalPage = 0
        //   }
        //   this.dataListLoading = false
        // }, false)
      },
      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getStudyCardList()
      },
      // 当前页
      currentChangeHandle (val) {
        this.pageIndex = val
        this.getStudyCardList()
      },
      addInfoHandle () {
        this.addVisible = true
        this.$nextTick(() => {
          this.$refs.addInfo.init()
        })
      },
      formInfoHandle (id) {
        this.addVisible = true
        this.$nextTick(() => {
          this.$refs.addInfo.init(id)
        })
      },
      editInfoHandle (id) {
        this.addVisible = true
        this.$nextTick(() => {
          this.$refs.addInfo.init(id)
        })
      },
      deleteHandle (id) {
        this.addVisible = true
        this.$nextTick(() => {
          this.$refs.addInfo.init(id)
        })
      }
    }
  }
</script>

<style scoped>

</style>
